home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gnats.idb / usr / freeware / lib / gnats / rmcat.z / rmcat
Encoding:
Text File  |  1999-04-16  |  2.3 KB  |  74 lines

  1. #!/bin/sh
  2. # Delete a category from GNATS.
  3. # Copyright (C) 1993 Free Software Foundation, Inc.
  4. # Contributed by Brendan Kehoe (brendan@cygnus.com).
  5. #
  6. # This file is part of GNU GNATS.
  7. #
  8. # GNU GNATS is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2, or (at your option)
  11. # any later version.
  12. #
  13. # GNU GNATS is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with GNU GNATS; see the file COPYING.  If not, write to
  20. # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. GNATS_ROOT=/usr/freeware/lib/gnats/gnats-db
  23. GNATS_SITE=humu
  24. DATADIR=/usr/freeware/lib
  25.  
  26. if [ $# -eq 0 ]; then
  27.   echo "usage: $0 category [category...]"
  28.   exit 1
  29. fi
  30.  
  31. # Newer config information?
  32. [ -f ${GNATS_ROOT}/gnats-adm/config ] && . ${GNATS_ROOT}/gnats-adm/config
  33.  
  34. if [ ! -d $DATADIR/gnats/dist ]; then
  35.   echo "$0: No directory $DATADIR/gnats/dist!"
  36.   exit 1
  37. fi
  38.  
  39. if [ ! -d $DATADIR/gnats ]; then
  40.   echo "$0: $DATADIR/gnats/$GNATS_SITE doesn't exist"
  41.   exit 1
  42. fi
  43.  
  44. for i in $*; do
  45.  
  46.     c=`grep "^$i:" $GNATS_ROOT/gnats-adm/categories`
  47.     if [ "$c" != "" ]; then
  48.       echo "$0: category $i is still in the categories file, please remove it."
  49.       continue
  50.     fi
  51.     if [ ! -d $GNATS_ROOT/$i ]; then
  52.       echo "$0: no directory for category $i"
  53.       continue
  54.     fi
  55.     if [ "`ls $GNATS_ROOT/$i/* 2>/dev/null`" != "" ]; then
  56.       echo "$0: bug reports are still in $i, remove them or recategorize them."
  57.       continue
  58.     fi
  59.     echo Trying to delete $i...
  60.     # Can't test return value of rmdir on old SunOSes...rrgh
  61.     rmdir $GNATS_ROOT/$i 2>/dev/null
  62.     if [ -d $GNATS_ROOT/$i ] ; then
  63.       echo "$0: could not remove $GNATS_ROOT/$i"
  64.       continue
  65.     fi
  66.     sed -e "/^$i$/d" $DATADIR/gnats/dist/categories > $DATADIR/gnats/dist/categories.tmp
  67.     mv -f $DATADIR/gnats/dist/categories.tmp $DATADIR/gnats/dist/categories
  68.     sed -e "/^$i$/d" $DATADIR/gnats/$GNATS_SITE > $DATADIR/gnats/$GNATS_SITE.tmp
  69.     mv -f $DATADIR/gnats/$GNATS_SITE.tmp $DATADIR/gnats/$GNATS_SITE
  70.  
  71. done
  72.  
  73. exit 0
  74.